package top.onedream.buildsmallsoftware.cfg

import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.InterceptorRegistry

import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
import top.onedream.buildsmallsoftware.cfg.Interceptor.JwtInterceptor
import top.onedream.buildsmallsoftware.cfg.Interceptor.TokenInterceptor


@Configuration
class WebInterceptorConfig(
    private val jwtInterceptor: JwtInterceptor,
    private val tokenInterceptor: TokenInterceptor
) : WebMvcConfigurationSupport() {
    //    @Resource
//    private val myInterceptor: MyInterceptor? = null
    public override fun addInterceptors(registry: InterceptorRegistry) {
        // 注册拦截器，要声明拦截器对象和要拦截的请求
        registry.addInterceptor(jwtInterceptor)
            .addPathPatterns("/**") //所有路径都被拦截
            .excludePathPatterns("/user/login*","/ws*") // 排除用户登录请求
        registry.addInterceptor(tokenInterceptor)
            .addPathPatterns("/**") //所有路径都被拦截
            .excludePathPatterns("/user/login*","/ws*") // 排除用户登录请求
    }
}